<?php
/**
 * DESCRIPTION:
 *  main file
 * ======
 * @author at8eqeq3
 * @version 0.1
 */
//set level of error reporting here:
//error_reporting(E_ALL & ~E_NOTICE);

//if this var is not set or set to false, nothing will work
global $up_and_running;
$up_and_running = 'true';

//autoloader loads everything we need
include 'utils/autoloader.php';

//we need a database
connect();

//also session
session_start();
if(!isset($_SESSION['errmsg']['global'])){
    $_SESSION['errmsg']['global'] = array();
}

//some more init actions...
if(!isset($_GET['module'])){
    $_GET['module'] = 'main';
}
global $module;
$module = new module($_GET['module']);

//if somebody logged in, let's know who he is
global $cur_user;
if(isset($_SESSION['user_id'])){
    $cur_user = new user($_SESSION['user_id']);
    $cur_user->getextrainfo();
    if(!$cur_user->fields['activated']){
        array_push($_SESSION['errmsg']['global'], "Ваш аккаунт необходимо <a href=\"/activate\">активировать</a>");
    }
}else{
    $cur_user->fields['login']='guest';
    $cur_user->fields['accesslevel']='0';
}

//add some javascript...
$js = array('resources/prototype_1.6.0.2/prototype-1.6.0.2.js', 'resources/scriptaculous_js_1.8.1/src/scriptaculous.js');

//and here is everything goes to browser
htmlout::set_theme('debug');
htmlout::print_header($module->fields['header'], 'UTF-8', null, $js);
htmlout::print_pageheader();
htmlout::print_pagecontent($module);
htmlout::print_sidebar();
echo "<br class=\"clearfloat\">";
//$u = new user(1);
htmlout::print_pagefooter();
htmlout::print_footer();
?>